class CmdMoveSelection:
    def __init__(self, diagram_view, views, x0, x1, y0, y1):
        self.diagram_view = diagram_view
        #Backing up affected views
        self.affected_views = [v for v in views if v.is_selected()]
        #Backing up original positions
        self.original_positions = {}
        for av in self.affected_views:
            self.original_positions[av] = av.get_position_backup()
        #Backing up mouse movement information
        self.x0 = x0
        self.y0 = y0
        self.x1 = x1
        self.y1 = y1

    def execute(self):
        dx = self.x1 - self.x0
        dy = self.y1 - self.y0
        for v in self.affected_views:
            newx = self.original_positions[v][0] + dx
            newy = self.original_positions[v][1] + dy
            v.prepare_move(newx, newy)
            v.move()
            v.discard_position_backup()
        self.diagram_view.redraw()
    
    def reverse(self):
        for v in self.affected_views:
            oldx = self.original_positions[v][0]
            oldy = self.original_positions[v][1]
            v.prepare_move(oldx, oldy)
            v.move()
        self.diagram_view.redraw()
